<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="java.sql.*"
 %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Annonce Fields</title>
</head>
<body>
 <%
Connection conn=null;
Statement stmt=null,stmt2=null;
try{
	Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
	System.out.print("la classe est introuvale");
	e.printStackTrace();
	}
try{
	String url="jdbc:mysql://localhost:3306/base_labrocante";
	String user="root";
	String pw="";
	conn=DriverManager.getConnection(url,user,pw);
	stmt = conn.createStatement();
	stmt2 = conn.createStatement();
	String login=(String) session.getAttribute("login");
	int iduser=Integer.parseInt(""+session.getAttribute("iduser"));
	String req1="select * from categorie";
	String req2="select * from ville";
	ResultSet rset=stmt.executeQuery(req1);
	ResultSet rset2=stmt2.executeQuery(req2);

%>

<h2>Annonce Page</h2>
<form action="insertAnnonce_2.jsp" method="post">
	<table>
		<tr>
			<td>Titre: </td>
			<td><input type="text" name="titre" ></td>
		</tr>
		<tr>
			<td>Annonce Description: </td>
			<td><textarea rows="5" cols="20" name="texteAnnonce"></textarea></td>
		</tr>
		<tr>
			<td>Telephone: </td>
			<td><input type="text" name="tel"></td>
		</tr>
		<tr>
			<td>prix: </td>
			<td><input type="text" name="prix"></td>
		</tr>
		<tr>
			<td>ville: </td>
			<td><select name=ville>

	<% while(rset2.next())
	out.print("<option value='"+rset2.getString("nomVille")+"'>"+rset2.getString("nomVille")+"</option>");
%>
</select></td>
		</tr>
		<tr>
			<td>Categorie: </td>
			<td><select name=categorie>

	<% while(rset.next())
	out.print("<option value='"+rset.getString("nomCat")+"'>"+rset.getString("nomCat")+"</option>");
	

%>
</select></td>
		</tr>
		
	</table>
	<input type="submit" name="submit" value="Ajouter" >
</form>

<%
}
catch(SQLException e){
e.printStackTrace();
}
%>
</body>
</html>